Repository navigation
COSMIC applet + shared battery UX, udev fix, XInput charging - #1
Merged
Merged
Conversation
vdemonchy
marked this pull request as draft
June 4, 2026 08:51
Adds cosmic-applet/ with a minimal libcosmic skeleton that compiles and renders an input-gaming-symbolic icon button in the COSMIC panel. Pinned to libcosmic rev f0f68933 (master HEAD); requires Rust 1.93. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds AppletConfig with CosmicConfigEntry derive (poll_interval=60,
display_mode=IconText, show_controller_icon=true), daemon_config_dir()
honoring XDG_CONFIG_HOME, and write_daemon_interval() that writes the
exact bytes {"interval_seconds":N} expected by the daemon.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Implements the full libcosmic Application for the cyclone2-applet: re-reads daemon state on each watcher tick, renders the panel button (respecting visibility/display mode/controller-icon settings), and a popup showing Mode + Battery with settings controls that persist via cosmic-config and write the daemon's config.json. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The rule used GROUP="plugdev", which does not exist on Arch/CachyOS, so udev rejected the whole rule line and never applied uaccess — leaving the controller's hidraw node root-only and the daemon unable to read the battery (permission denied). Rely solely on TAG+="uaccess", the distro-agnostic logind mechanism; drop the redundant plugdev group/MODE. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Wrap the panel view in autosize_window and render the icon(s) + text inside a single AppletIcon button, so the surface sizes to its content and the indicator reads as one cohesive element (previously the text was clipped and the controller icon hid the rest). - Drop the redundant battery glyph: the controller icon is now the sole icon and is tinted by battery level — green (>=60) / yellow (>=25) / red (<25) — falling back to the panel foreground colour when the level is unknown (missing / stale). - Always show the controller icon; remove the show-controller-icon toggle. - Reduce display modes to Icon only / Icon + text (drop Text only). - Rename the popup label "Mode:" to "Cyclone 2 mode:". - README: document the level colours, two display modes, and that the system power panel (UPower) is only reliable in Switch mode. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the COSMIC applet changes in the GNOME extension: - Drop the redundant battery icon; the controller icon is the sole icon, tinted by battery level — green (>=60) / yellow (>=25) / red (<25) — via St.Icon CSS colour, neutral when the level is unknown (stale / no battery). - Always show the controller icon; remove the show-controller-icon setting (gschema key + prefs switch). - Reduce display modes to Icon only / Icon + text (drop Text only). - Rename the popup label "Mode:" to "Cyclone 2 mode:". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`@victor.local` is a reserved mDNS TLD, not an ownable domain, and a poor UUID for a publicly shared extension. Rename to namespaces tied to the GitHub account: - GNOME extension UUID: cyclone2-battery@vdemonchy.github.io (dir, metadata.json, install.sh, README enable command). - COSMIC applet app id: io.github.vdemonchy.Cyclone2Battery (APP_ID, .desktop filename, install.sh). The gschema id and the extension JS don't reference the UUID, so they need no change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Post a desktop notification (via gdbus, so no D-Bus dependency) when the battery first drops to or below a configurable threshold. The notifier is edge-triggered with a 5% hysteresis margin and re-arms on charge/disconnect, so a level hovering near the threshold doesn't spam the user. Stale/unknown readings are ignored. Threshold comes from config.json (low_battery_threshold; 0 disables). Because the daemon reads the correct per-mode value, this works accurately in all battery modes — including XInput and DS4, which the system power panel (UPower) can't report correctly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Always show the charge state in the popup ("— Charging" / "— On battery").
- Breathe the icon while charging: a sine-driven brightness pulse (~2s cycle,
~40% floor) via a timer subscription that runs only while charging.
- Configurable low-battery alert threshold (0–50% stepper, default 20%),
written to the daemon's config.json alongside the poll interval (synced on
startup too).
- Configurable battery level colors: green/yellow thresholds (defaults 60/25),
with the green threshold constrained to stay above the yellow one.
- Rename the popup "Mode:" label to "Cyclone 2 mode:".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…(parity)
Mirror the COSMIC applet's new behavior in the GNOME extension:
- Always show the charge state in the menu ("— Charging" / "— On battery").
- Breathe the controller icon while charging via a looping, auto-reversing,
sine-eased Clutter opacity transition (~2s cycle, ~40% floor).
- Configurable low-battery alert threshold (0–50% SpinRow, default 20%),
written to config.json for the daemon.
- Configurable battery level colors: green/yellow thresholds (defaults 60/25),
with each spinner bounded so green stays above yellow.
- Rename the popup "Mode:" label to "Cyclone 2 mode:".
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The XInput 0x12 report's charging flag is byte 35 (0 on battery, 1 plugged), not byte 37. Confirmed by capturing frames across plug → unplug → plug cycles: byte 35 tracked the cable state exactly while byte 37 stayed 0. The old code read byte 37, so XInput charging never registered. Read byte 35 instead, fix the bounds check (percent at 36 is now the highest index), and add a parser test built from the real captured frames. Update docs/protocol.md and the README to mark the flag confirmed. Charging now works natively in all modes: DS4/Switch via the kernel power_supply cable-state, XInput via byte 35. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vdemonchy
marked this pull request as ready for review
June 5, 2026 09:52
When the controller disconnected (Display::Hidden), view() returned a bare Space that bypassed autosize_window, so the panel kept the applet surface at its last size and left an empty gap. Wrap the empty element in autosize_window so the surface shrinks to zero and the slot disappears. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a native libcosmic panel applet as a second frontend for the
cyclone2daemon (bringing the battery indicator to COSMIC / CachyOS at parity with the GNOME extension), and builds out a shared battery UX across both frontends: configurable low-battery notifications, an always-visible charge state, a level-colored controller icon that breathes while charging, and configurable thresholds. Also fixes a CachyOS udev bug and the reverse-engineered XInput charging flag, and cleans up the public naming.Highlights
COSMIC applet (new frontend)
cosmic-applet/Rust crate (libcosmic pinned), implementing the daemon's file-only contract: reads the runtime state JSON, writesconfig.json.autosize_window.cosmic-config).Shared battery UX (COSMIC applet + GNOME extension)
— Charging/— On battery).Mode:→Cyclone 2 mode:.Configurable low-battery notifications (daemon)
gdbus, no D-Bus dependency) when the battery first drops to/below a configurable threshold (0–50%, default 20%, 0 disables). Edge-triggered with hysteresis; re-arms on charge/disconnect; ignores stale/unknown readings. Works accurately in all modes — including XInput/DS4, which UPower can't report correctly.Fixes
GROUP="plugdev"(nonexistent on Arch, which made the whole rule fail) and rely onTAG+="uaccess". This was the root cause of the indicator not working on CachyOS.0x12report's charging/cable flag is byte 35 (not byte 37, which never changes) — confirmed via plug/unplug captures and covered by a parser test from the real frames. Charging now works in XInput too.Naming
cyclone2-battery@vdemonchy.github.io; COSMIC app id →io.github.vdemonchy.Cyclone2Battery(the old@victor.local/dev.victorplaceholders aren't suitable for public sharing).Notes
Testing
go build ./...,go vet,go test ./...(incl. new notifier and real-frame charging parser tests) pass.cargo build --release+cargo testpass.glib-compile-schemas --strict --dry-run).🤖 Generated with Claude Code